package com.example.output;

import cn.hutool.core.annotation.Alias;
import com.example.entity.Columns;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class ExcelInfo {
    @Alias(value = "数据库名")
    private String tableSchema;
    
    @Alias(value = "表名")
    private String tableName;
    
    @Alias(value = "字段名")
    private String columnName;
    
    @Alias(value = "字段类型")
    private String columnType;
    
    @Alias(value = "是否主键")
    private String columnKey;
    
    @Alias(value = "是否为空")
    private String isNullable;
    
    @Alias(value = "描述信息")
    private String columnComment;
    
    public static ExcelInfo toDto(Columns columns) {
        ExcelInfo res = new ExcelInfo();
        res.setTableSchema(columns.getId().getTableSchema());
        res.setTableName(columns.getId().getTableName());
        res.setColumnName(columns.getId().getColumnName());
        res.setColumnType(columns.getColumnType());
        res.setColumnKey("PRI".equals(columns.getColumnKey()) ? "是" : "否");
        res.setIsNullable("YES".equals(columns.getIsNullable()) ? "是" : "否");
        res.setColumnComment(columns.getColumnComment());
        return res;
    }
}
